<? $page_title='报价信息' ?>
<? include "FASHION/page_header.phtml" ?>

<style>
.cost{ width:80px; }
#stuffs{ display:none; }
</style>

<FORM id="form1" METHOD=POST >
<TABLE class="select">
<TR>
	<TD class="tRight" width="20%">供应商：</TD>
	<TD class="tLeft" ><select name="supplier_id" id="supplier_id" onchange="defpg()">
	<option value=""></option>
<{foreach item=s from=$suppliers}>
	<option value="<{$s.id}>"><{$s.name}></option>
<{/foreach}>
	</select></TD>
	<td class="right" width="20%">关键字</td>
	<td class="left nobr" width="30%"><input type="text" value="<?= fetch_a_string('keyw') ?>" id="keyw" size="12" />
		<input type="button" value="搜索" onclick="defpg()" class="button" /></td>
</TR>
</TABLE>

<table class="list" id="stuffs">
<tr class="nobg">
	<th>材料编号</th>
	<th>材料名称</th>
<!--	<th>参考单价</th>-->
	<th>品牌</th>
	<th width="120">规格</th>
	<th>单位</th>
	<th>供应报价</th>
	<!--<th width="120">备注</th>-->
</tr>
<{foreach item=s from=$stuffs}>
<tr>
	<td class="nobr"><{$s.sno}></td>
	<td><{$s.name}></td>
<!--	<td class="nobr right fnum"><{$s.price}> 元</td>-->
	<td><{$s.brand}></td>
	<td><{$s.specific}></td>
	<td><{$s.unit}></td>
	<td class="nobr"><input type="text" name="cost[<{$s.id}>]" id="cost_<{$s.id}>" value=""
						class="cost decimal fnum" onfocus="chkdig_float(this)"/>元</td>
</tr>
<{/foreach}>
<TR>
	<TD colspan="6" class="center">
		<INPUT TYPE="button" value="返 回" onclick="location.href='<? url('supplier-quote') ?>'"> &nbsp;
		<INPUT TYPE="submit" value="提 交">
	</TD>
</TR>
</table>
</FORM>

<?= Html::pager($pager) ?>

<script language="JavaScript">
$(document).ready(function(){
	$('#supplier_id').val('<? fetch_a_int('id') ?>');
	get_cost('<? fetch_a_int('id') ?>');
	//disable autocomplate(input history)
	$('.cost').attr('autocomplete', 'off');
	$('.cost').attr('disableautocomplete', true);
	ajax_form({id:'form1',before:function(){ return confirm('确认提交<?$page_title?>吗？');}});
});

function get_cost(splr_id) {
	$('input.cost').val('');
	if(!splr_id){
		$('table#stuffs').hide();
		return;
	}
	$('table#stuffs').show();
	$.get('<? url('supplier-offer/sid/SP_ID') ?>'.replace('SP_ID',splr_id), function(jsn){
		if(jsn.list) for(var i in jsn.list) {
			$('#cost_'+jsn.list[i].ware_id).val(jsn.list[i].quote);
		}
	});
}
function defpg()
{
	location.href='<? url('supplier-quote/id/SPID/keyw/KEYW') ?>'
		.replace('SPID',$('#supplier_id').val())
		.replace('KEYW', $('#keyw').val());
}
</script>

<? include "FASHION/page_footer.phtml" ?>
